<template>
    <Card :bordered="false" dis-hover :animated="false">
        <Tabs v-model="name" name="business" @on-click="changeTabs">
             <TabPane label="站点/专题配置" v-if="tab1" name="name1" tab="business">
                <tablename1 ref="tablename1"/>
            </TabPane>
            <TabPane label="全局通用配置" v-if="tab2" name="name2" tab="business">
                <tablename2 ref="tablename2"/>
            </TabPane>
             <TabPane label="配置管理" v-if="tab3" name="name3" tab="business">
                <tablename3  ref="tablename3"/>
            </TabPane>
        </Tabs>
    </Card>
</template>

<script>
    import tablename1 from './tablename1.vue'
    import tablename2 from './tablename2.vue'
    import tablename3 from './tablename3.vue'
    import util from '@/libs/util';
    export default {
        name: 'business',
        components: { tablename1, tablename2, tablename3 },
        data () {
            return {
                name: 'name1',
                tab1: true,
                tab2: true,
                tab3: true,
                butshow: {
                    tab1: {
                        name: '-v1-swt-swt-domain-zt-get-domain-zt',
                        flag: '/'
                    },
                    tab2: {
                        name: '-v1-swt-swt-get-swt-project',
                        flag: '/'
                    },
                    tab3: {
                        name: '-v1-swt-swt-get-swt2',
                        flag: '/'
                    }
                }
            };
        },

        mounted () {
            let menus = util.storage.get('menus');
            let power = menus.action;
            let flag1 = power.find(ee => {
                return ee.flag === this.butshow.tab1.flag && ee.marking === this.butshow.tab1.name
            })
            let flag2 = power.find(ee => {
                return ee.flag === this.butshow.tab2.flag && ee.marking === this.butshow.tab2.name
            })
            if (typeof (flag1) !== 'undefined') this.tab1 = true
            else this.tab1 = false
            if (typeof (flag2) !== 'undefined') {
                this.tab2 = true
                if (!this.tab1) this.name = 'name2'
            } else this.tab2 = false
            // console.log(this.tab1, this.tab2, '11')
        },
        methods: {
            changeTabs(name){
                if(name=='name1'){
                    this.$refs.tablename1.initial()
                }else if(name=='name2'){
                    this.$refs.tablename2.initial()
                }else{
                    this.$refs.tablename3.initial()
                }
            }
        }
    };
</script>

<style lang="less" scoped>

</style>
